package org.cytoscape.myapp.my_cyaction_app.internal;

import java.util.Properties;

import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.application.CyVersion;
import org.cytoscape.application.swing.CySwingApplication;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.event.CyEventHelper;
import org.cytoscape.model.CyNetworkFactory;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTableFactory;
import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.service.util.AbstractCyActivator;
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.view.model.CyNetworkView;

import org.cytoscape.view.presentation.RenderingEngineFactory;
import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
import org.cytoscape.view.vizmap.VisualMappingManager;
import org.cytoscape.view.vizmap.VisualStyleFactory;
import org.cytoscape.work.TaskManager;
import org.osgi.framework.BundleContext;
import org.cytoscape.view.model.CyNetworkViewFactory;
import org.cytoscape.view.model.CyNetworkViewManager;

public class CyActivator extends AbstractCyActivator {

	@Override
	public void start(BundleContext bc) throws Exception {
		
		
		/*
		 * Creo MyNet para caso de prueba
		 */
		CyApplicationManager appManager = getService(bc, CyApplicationManager.class);
		
		CyNetworkFactory networkFactory = getService(bc, CyNetworkFactory.class);
		CyEventHelper event = getService(bc, CyEventHelper.class);
		CyNetworkManager networkManager = getService(bc, CyNetworkManager.class);
	
		MyNetwork myNet = new MyNetwork(networkFactory,event,networkManager);
		myNet.CreateNetwork(20);
		
		//CyNetworkManager networkManager = getService(bc, CyNetworkManager.class);
		
		networkManager.addNetwork(myNet.getMyNetwork());
		

		 /*
		  *  Creo y agrego la vista de MyNet
		  */
		
		CyNetworkViewFactory networkViewFactory = getService(bc, CyNetworkViewFactory.class);
		
		CyNetworkView myView = networkViewFactory.createNetworkView(myNet.getMyNetwork());

		CyNetworkViewManager networkViewManager = getService(bc, CyNetworkViewManager.class);
		
		//networkViewManager.addNetworkView(myView);
		
		/*
		 *Agrego submenu ejemplo al menu principal
		 */
		
		/*CyApplicationManager cyApplicationManager = getService(bc, CyApplicationManager.class);*/
		
	//	MenuAction action = new MenuAction(appManager, "Hello World App");
		
		Properties properties = new Properties();
		 /*
		  *  Creo Panel  Principal
		  */
	//	registerAllServices(bc, action, properties);
		
		MyCytoPanel myPanel = new MyCytoPanel(appManager,myNet,networkManager);
		
		/*
		 * Registro todos los servicios 
		 */
		
		registerService(bc,myPanel,CytoPanelComponent.class,properties);
		
		
		
	}

}
